#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

class Graphic
{
public:
    virtual  void move(int x, int y) = 0;
    virtual  void draw() = 0;
};

class Dot : public Graphic
{
protected:
    int x, y;
public:
    Dot(int x_, int y_)
    :x(x_),y(y_)
    {
    }
    void move(int x_, int y_) override
    {
        x = x_;
        y = y_;
    }
    void draw() override
    {
        std::cout<<"draw dot at("<<x<<","<<y<<")"<<std::endl;
    }
};

class CirCle : public Dot
{
private:
    int radius;
public:
    CirCle(int x, int y, int radius_)
    :Dot(x,y),radius(radius_)
    {
    }
    void draw() override
    {
        std::cout<<"draw CirCle at("<<x<<","<<y<<","<<radius<<")"<<std::endl;
    }
};

class CompoundGraphic : public Graphic
{
private:
    std::vector<Graphic*> children;
public:
    CompoundGraphic()
    {
    }
    void add(Graphic* child)
    {
        children.push_back(child);
    }
    void remove(Graphic* child)
    {
        children.erase(find(children.begin(), children.end(), child));
    }
    void move(int x,int y)override
    {
        for(auto c : children)
            c->move(x, y);
    }
    void draw()override
    {
        for(auto c : children)
            c->draw();
    }
};

int main() {

    CompoundGraphic* graphic = new CompoundGraphic();
    graphic->add(new Dot(1,2));
    graphic->add(new CirCle(1,2,2));
    CompoundGraphic* root = new CompoundGraphic();
    root->add(new Dot(3,4));
    root->add(new CirCle(3,4,6));
    root->add(graphic);
    root->draw();
    return 0;
}



